package framework;

import utils.ArrayUtils;
import utils.Log;

/**
 * Created by shane on 2018/5/20.
 */
public abstract class AbstractTest implements Testable {
    protected String TAG = "AbstractTest";

    @Override
    public void test(String[] args) {
        Log.vn("======>>testing..." + getTag());
    }

    protected String getTag() {
        return TAG;
    }

    protected final String getDefInputFile(String[] args) {
        String filePath = DEFAULT_INPUT_FILE;
        if (!ArrayUtils.isEmpty(args)) {
            filePath = args[0];
        }

        return filePath;
    }

    protected final String getDefOutputFile(String[] args) {
        String filePath = DEFAULT_OUTPUT_FILE;
        if (!ArrayUtils.isEmpty(args)) {
            filePath = args[0];
        }

        return filePath;
    }

    protected final String getDefTempFile(String[] args) {
        String filePath = DEFAULT_TEMP_FILE;
        if (!ArrayUtils.isEmpty(args)) {
            filePath = args[0];
        }

        return filePath;
    }

    protected final String getDefMmapFile(String[] args) {
        String filePath = DEFAULT_MMAP_FILE;
        if (!ArrayUtils.isEmpty(args)) {
            filePath = args[0];
        }

        return filePath;
    }

    protected final void profileTest() {
        Log.v("TAG:" + TAG + ",");
        try {
            long start = System.nanoTime();
            test(null);
            double duration = System.nanoTime() - start;
            System.out.format("%.2f\n", duration/1.0e9);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
